import Request from './request.js'

const API = {
	queryCityList: '/app/bus/area/letterList',
	getCityCode: '/app/bus/area/position',
	getCityFromCode: '/app/bus/area/jurisdiction',
	getQiNiuUpToken: '/app/bus/qiNiuAuth/getQiNiuUpToken',
	getUpdateAsyncPos: '/app/bus/position/edit'
}

// 查询城市列表
export const queryCityList = (params) => {
	// params 应包含 longitude（经度）、latitude（纬度），比如 { longitude: 112.565659, latitude: 37.736525 }
	return Request.get(API.queryCityList, {
		data: params
	});
};

// 查询城市编码
export const queryCityCode = (params) => Request.get(API.getCityCode, {
	data: params
})

// 根据城市编码查询城市
export const queryCityFromCode = (params) => Request.get(API.getCityFromCode, {
	data: params
})

// 获取七牛云上传token
export const getQiNiuUpToken = () => Request.get(API.getQiNiuUpToken)

// 异步更新位置
export const updateAsyncPosition = (data) => {
  // 直接传递 data 作为请求体，不再嵌套
  return Request.post(API.getUpdateAsyncPos, data);
};